﻿using DDD.Domain;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DDD.EFCore
{
    public abstract class Query<TDbContext, TEntiy> : IAsQueryable<TEntiy>
        where TDbContext : EFContext<TDbContext>
        where TEntiy : Entity, IAggregateRoot
    {
        protected virtual TDbContext DbContext { get; set; }

        protected Query(TDbContext DbContext)
        {
            this.DbContext = DbContext;
        }

        public System.Linq.IQueryable<TEntiy> AsQueryable()
        {
            return DbContext.Set<TEntiy>().AsNoTracking().Where(e => e.IsDeleted == false);
        }
    }
}

